package org.blogwu.learn.designpattern.chapter8.enuminstance;

import java.io.*;

public class Test {

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {

        EnumInstance enumInstance = EnumInstance.getInstance();
        enumInstance.setObject(new Object());
        System.out.println(enumInstance);
        System.out.println(enumInstance.getObject());
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("/Users/zsyubo/Documents/temp/xx.obj"));
        objectOutputStream.writeObject(enumInstance);


        File file = new File("/Users/zsyubo/Documents/temp/xx.obj");
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
        EnumInstance oldEnumInstance = (EnumInstance) objectInputStream.readObject();
        System.out.println(oldEnumInstance);
        System.out.println(oldEnumInstance.getObject());
    }
}
